package com.efuture.io;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * @ClassNAME FileInputStreamTest
 * @Description 该类主要展示FileInputStreamTest(输入流)的使用
 * @Author zhaoshanshan
 * @Date 2021/9/8 8:43 下午
 * @Version 1.0
 */
public class FileInputStreamTest {

    public static void main(String[] args) {
        FileInputStream fis = null;
        try{
             fis = new FileInputStream("javasestudy/src/com.efuture.io/TestFileOne.txt");
             int readCount = -1;
             byte[] bytes = new byte[128];
             while ((readCount=fis.read(bytes))!=-1){//当读取的值返回为-1代表读取到了文件的末尾
                 System.out.print(new String(bytes,0,readCount,"UTF-8"));
             }
        }catch (IOException e){
            e.getStackTrace();
        }finally {
            if(null!=fis){
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}